<template>
    <div class="line">
        <!--可以使用watch属性监听，父组件传递过来的max值-->
        <div class="mui-numbox" data-numbox-min='1' data-numbox-max='9'>
            <button class="mui-btn mui-btn-numbox-minus" type="button" >-</button>
            <input id="test" class="mui-input-numbox" type="number" value="1" @change="countChanged" ref="numbox"/>
            <button class="mui-btn mui-btn-numbox-plus" type="button" >+</button>
        </div>
    </div>
</template>

<script>
    import mui from '../../lib/mui/js/mui.min.js'
    export default {
       name: "goodsinfo_numberbox",
        props:["max"],           //父组件传递过来的值
       mounted() {
            mui(".mui-numbox").numbox();
       },
        methods:{
            countChanged(){
                console.log(this.$refs.numbox.value)
                this.$emit('getcount',parseInt(this.$refs.numbox.value))
            }
        },
        watch:{
            'max':function (newVal,oldVal) {
                mui(".mui-numbox").numbox().setOption('max',newVal)
            }
        }
    }
</script>

<style scoped>
.line{
    display: inline;
}
</style>